unit uSprites;

interface

uses Graphics, uUtils;

const
  TilesetCount = 2;
  SpritesCount = 50;
  spObj = 0; 
  spCrt = 1; 

var
  Sprite: array [0..TilesetCount - 1, 0..SpritesCount - 1] of TBitmap;

implementation

uses SysUtils;

procedure Load;
var
  I, J: Byte;
  Tileset: TBitmap;
begin
  for J := 0 to TilesetCount - 1 do 
  begin
    Tileset := TBitmap.Create;
    Tileset.LoadFromFile('Sprite' + IntToStr(J) + '.bmp');
    for I := 0 to SpritesCount - 1 do
    begin
      Sprite[J][I] := TBitmap.Create;
      BitmapFromTileset(Sprite[J][I], Tileset, I, 64);
      Sprite[J][I].Transparent := True;
    end;
    Tileset.Free;
  end;  
end;
    
procedure Free;    
var
  I, J: Byte;
begin
  for J := 0 to TilesetCount - 1 do 
    for I := 0 to SpritesCount - 1 do 
      Sprite[J][I].Free;
end;

initialization
  Load;

finalization 
  Free;

end.
